/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package SPMModel.impl;

import SPMModel.Artifact;
import SPMModel.ArtifactDescriptor;
import SPMModel.SPMModelPackage;
import SPMModel.Type;
import SPMModel.Variability;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Artifact Descriptor</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link SPMModel.impl.ArtifactDescriptorImpl#getVariability <em>Variability</em>}</li>
 *   <li>{@link SPMModel.impl.ArtifactDescriptorImpl#getType <em>Type</em>}</li>
 *   <li>{@link SPMModel.impl.ArtifactDescriptorImpl#getIs <em>Is</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArtifactDescriptorImpl extends EObjectImpl implements ArtifactDescriptor {
	/**
	 * The default value of the '{@link #getVariability() <em>Variability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVariability()
	 * @generated
	 * @ordered
	 */
	protected static final Variability VARIABILITY_EDEFAULT = Variability.MANDATORY;

	/**
	 * The cached value of the '{@link #getVariability() <em>Variability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVariability()
	 * @generated
	 * @ordered
	 */
	protected Variability variability = VARIABILITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final Type TYPE_EDEFAULT = Type.IN;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected Type type = TYPE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getIs() <em>Is</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIs()
	 * @generated
	 * @ordered
	 */
	protected Artifact is;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ArtifactDescriptorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SPMModelPackage.Literals.ARTIFACT_DESCRIPTOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Variability getVariability() {
		return variability;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setVariability(Variability newVariability) {
		Variability oldVariability = variability;
		variability = newVariability == null ? VARIABILITY_EDEFAULT : newVariability;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.ARTIFACT_DESCRIPTOR__VARIABILITY, oldVariability, variability));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Type getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(Type newType) {
		Type oldType = type;
		type = newType == null ? TYPE_EDEFAULT : newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.ARTIFACT_DESCRIPTOR__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Artifact getIs() {
		if (is != null && is.eIsProxy()) {
			InternalEObject oldIs = (InternalEObject)is;
			is = (Artifact)eResolveProxy(oldIs);
			if (is != oldIs) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, SPMModelPackage.ARTIFACT_DESCRIPTOR__IS, oldIs, is));
			}
		}
		return is;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Artifact basicGetIs() {
		return is;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIs(Artifact newIs) {
		Artifact oldIs = is;
		is = newIs;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SPMModelPackage.ARTIFACT_DESCRIPTOR__IS, oldIs, is));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__VARIABILITY:
				return getVariability();
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__TYPE:
				return getType();
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__IS:
				if (resolve) return getIs();
				return basicGetIs();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__VARIABILITY:
				setVariability((Variability)newValue);
				return;
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__TYPE:
				setType((Type)newValue);
				return;
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__IS:
				setIs((Artifact)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__VARIABILITY:
				setVariability(VARIABILITY_EDEFAULT);
				return;
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__TYPE:
				setType(TYPE_EDEFAULT);
				return;
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__IS:
				setIs((Artifact)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__VARIABILITY:
				return variability != VARIABILITY_EDEFAULT;
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__TYPE:
				return type != TYPE_EDEFAULT;
			case SPMModelPackage.ARTIFACT_DESCRIPTOR__IS:
				return is != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (variability: ");
		result.append(variability);
		result.append(", type: ");
		result.append(type);
		result.append(')');
		return result.toString();
	}

} //ArtifactDescriptorImpl
